/*
 * @Descripttion: 
 * @version: 
 * @Author: turingchang
 * @Date: 2020-08-28 14:32:50
 * @LastEditors: turingchang
 * @LastEditTime: 2020-09-08 14:56:57
 */

'use strict';
const BaseController = require('../base/base');

class AdminController extends BaseController {
    async list() {
        const ctx = this.ctx;
        var data = await ctx.service.admin.admin.list();
        data =ctx.convertToAntTableData(data);
        ctx.outSuccess(null, data);
    }
    async get() {
        const ctx = this.ctx;
        const {
            email,
            password
        } = ctx.query;
        var id = ctx.query.id;
        var admin =ctx.model.Admin.build();
        admin.name ='qqqqq';
        admin.password ='123';
        await admin.save();    
        console.log(666,admin.dataValues);    
        var data = await ctx.service.admin.admin.get(id);
        ctx.outSuccess(null, data);
    }
    async create() {
        const ctx = this.ctx;
        const {email,password} = ctx.query;
        const validateResult = await ctx.validate('admin.login', {email,password}); 
        if (!validateResult) {
            ctx.outValidateStatus();
            return;
        }
        // console.log(6666);
        var admin =ctx.model.Admin.Admin.build();
        var data = null;
        ctx.outSuccess(null, data);
    }

    async info(){
        const ctx = this.ctx;
        var data = await ctx.service.admin.admin.info();
        ctx.outSuccess(null, data);
    }
}

module.exports = AdminController;